﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>测试容器</title>
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <link href="../../Style/skin/css/style.css" rel="stylesheet" type="text/css" />
    <link href="../../Portal/icons/font-icons.min.css" rel="stylesheet" />
    <link href="../../Portal/icons/icons.css" rel="stylesheet" />
    <script src="../../Scripts/easyUI145/jquery.min.js" type="text/javascript"></script>
    <script src="../../Scripts/easyUI145/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery/jquery.min.js"></script>

    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../Comm/Gener.js" type="text/javascript"></script>
    <script src="../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
    <link href="../../Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" />
    <link href="../../Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <script src="../../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="../../Scripts/bootstrap/BootstrapUIDialog.js"></script>

    <script src="../Guide/Guide.js"></script>
    <script language="javascript" type="text/javascript">
        var workID = 0;
        var webUser = new WebUser();

        //负责人：@qfl
        $(function () {

            InitPageUserInfo();

            //获得参数.
            var flowNo = GetQueryString("FK_Flow");
            var flow = new Entity("BP.WF.Flow", flowNo);
            document.title = "测试容器:" + flow.Name;

            //第一次加载,如果没有传递过来workid.
            workID = GetQueryString("WorkID");
            if (workID == undefined || workID == null) {
                //访问后台，获得一个工作ID.
                var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_TestingContainer");
                handler.AddUrlData();
                var data = handler.DoMethodReturnString("Default_Init");
                if (data.indexOf('err@') == 0) {

                    var url = 'error.htm?err=' + data;

                    confirm("测试容器发起错误，请参考以下信息：<\br>" + data);
                    window.close();
                }
                var str = data.split('@');
                workID = str[0];
                localStorage.setItem("Token", str[1]);
                var webUser = new WebUser()
                var orgNo = GetQueryString("OrgNo");
                document.getElementById("J_iframe").src = "../../MyFlow.htm?FK_Flow=" + flowNo + "&WorkID=" + workID;

            } else {
                workID = GetQueryString("WorkID");
                SelectOneUser();
            }


        });
        


        function GenerUrlEnd() {
            var adminerToken = GetQueryString("AdminToken") || localStorage.getItem("AdminToken");

            //定义变量.
            var urlEnd = "&FK_Flow=" + GetQueryString("FK_Flow") + "&WorkID=" + workID + "&UserNo=" + webUser.No + "&OrgNo=" + webUser.OrgNo;
            urlEnd += "&Adminer=" + GetQueryString("Adminer");
            urlEnd += "&AdminToken=" + adminerToken;
            urlEnd += "&Token=" + webUser.Token;
            return urlEnd;
        }
        // 发送成功后刷新页面进入切换用户页面
        function refreshRight() {
            $("#J_iframe").attr('src', "SelectOneUser.html?1=2" + GenerUrlEnd());
        }

        //如果关闭的时候，就让admin登录.
        function LetAdminerLogin() {
            var token = GetQueryString("AdminToken") || localStorage.getItem("AdminToken"); //管理员SID.
            var userNo = GetQueryString("UserNo"); //管理员SID.
            var orgNo = GetQueryString("OrgNo"); //管理员SID.

            //if (token == null || token == "null") {
            //    alert("系统错误，丢失了登录信息 token ,请重新登录。");
            //    return;
            //}

            //访问后台，获得一个工作ID.
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_TestingContainer");
            handler.AddPara("Token", token);
            var data = handler.DoMethodReturnString("Default_LetAdminerLogin");
            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }
            localStorage.setItem("Token", token);
            var url = basePath + "/WF/Admin/CCBPMDesigner/Designer.htm?FK_Flow=" + GetQueryString("FK_Flow") + "&UserNo=" + data + "&Token=" + token;
            SetHref(url);
            return;

            window.close();
        }


        //页面启动函数.
        var sid = GetQueryString("AdminToken") || localStorage.getItem("AdminToken"); //管理员SID.
        // var workID = GetQueryString("WorkID");
        var userNo = GetQueryString("UserNo");
        var flowNo = GetQueryString("FK_Flow");
        // var urlEnd = "&FK_Flow=" + flowNo + "&WorkID=" + workID + "&UserNo=" + userNo + "&Token=" + sid;
        function InitPageUserInfo(token) {
            token = token || localStorage.getItem("Token");

            //先设置缓存为空.
            webUserJsonString = null;
            if (token != "") {
                var handler = new HttpHandler("BP.WF.HttpHandler.WF_Comm");
                handler.AddPara("Token", token);
                var data = handler.DoMethodReturnString("WebUser_Init");
                if (data.indexOf("err@") != -1) {
                    alert(data);
                    return;
                }
                webUserJsonString = JSON.parse(data);
            }
            var webUser = new WebUser();

            var html = "<table style='width:100%;'>";
            html += "<caption class='top_tiitle'><a class='title_content' href='javascript:LetAdminerLogin();' ><i class='icon-arrow-left' style='font-size:14px;margin-right: 5px;'></i>返回流程设计器 </a></caption>";
            html += "<tr>";
            html += "<td colspan=2 style='text-align:center'>";
            html += "<img style='width:50%;' src='../../../DataUser/UserIcon/" + webUser.No + ".png' onerror=\"this.src='../../../DataUser/UserIcon/Default.png'\" />";
            html += "</td>";
            html += "</tr>";

            html += "<tr>";
            html += "<td class='left-user-end'>帐号</td>";
            html += "<td class='left-user-left'>" + webUser.No + "</td>";
            html += "</tr>";

            html += "<tr>";
            html += "<td class='left-user-end' >用户</td>";
            html += "<td class='left-user-left'>" + webUser.Name + "</td>";
            html += "</tr>";

            html += "<tr>";
            html += "<td class='left-user-end' >部门</td>";
            html += "<td class='left-user-left'>" + webUser.FK_DeptName + "</td>";
            html += "</tr>";

            html += "<tr>";
            html += "<td class='left-user-end' >WorkID</td>";
            html += "<td class='left-user-left'>" + workID + "</td>";
            html += "</tr>";

            html += "<tr>";
            html += "<td class='left-user-end' >模板编号</td>";
            html += "<td class='left-user-left'>" + GetQueryString("FK_Flow") + "</td>";
            html += "</tr>";

            html += "</table>";

            $("#userInfo").html(html);

            var html = "<ul class='nav' id='side-menu'>";

            html += "<li>"
            html = "<ul style='border:solid 1px #C2D5E3;' id='choose-parent' >";
            html += "<li style='padding:5px;' ><a href='javaScript:void(0)' onclick='chageFramPage(this)' data-info='SelectOneUser.html?1=2' class='J_menuItem' ><i class='icon-user-following'></i>&nbsp;&nbsp;切换用户</a></li>";
            html += "<li style='padding:5px;'><a href='javaScript:void(0)'  onclick='chageFramPage(this)' data-info='DBInfo.html?1=2' class='J_menuItem' ><i class='icon-disc'></i>&nbsp;&nbsp;数据库信息</a></li>";
            //      html += "<li style='padding:5px;'><a href='javaScript:void(0)'  onclick='chageFramPage(this)' data-info='../../WFRpt.htm?1=2' class='J_menuItem' >轨迹图</a></li>";
            html += "<li style='padding:5px;'><a href='javascript:Restart();' ><i class='icon-power'></i>&nbsp;&nbsp;重新启动 </a></li>";
            html += "<li style='padding:5px;'><a href='javaScript:void(0)'  onclick='chageFramPage(this)' data-info='SelectGWF.html?1=2' class='J_menuItem' ><i class='icon-refresh'></i>&nbsp;&nbsp;切换测试实例</a></li>";
            //   html += "<li style='padding:5px;'><a href='javascript:LetAdminerLogin();' >安全退出 </a></li>";

            //var runModel = GetQueryString("RunModel");
            //if (runModel != 2) {
            //    html += "<li style='padding:5px;'><a href='javascript:ToLogin();'  >登录到前台</a></li>";
            //}

            html += "</ul>";
            html += "</li>";
            html += "</ul>";
            $("#Info").html(html);

            
            //$('#choose-parent li').on("click", function () {
            //    $("#choose-parent li.choose-active").removeClass("choose-active")
            //    $(this).addClass("choose-active");
            //})
            // $("#BaseInfo").html();
        }
        function ToLogin() {

            if (window.confirm('您确定要退出吗？') == false)
                return;

            var url = "../../AppClassic/Login.htm";
            window.open(url);
            SetHref(url); //可以关闭窗口.
        }
        function chageFramPage(obj) {
            var url = $(obj).attr('data-info');

            var orgNo = GetQueryString("OrgNo");

            // var adminer = GetQueryString("Adminer"); //管理员.
            var token = GetQueryString("AdminToken") || localStorage.getItem("AdminToken"); //管理员SID.
            var userNo = GetQueryString("UserNo"); //管理员SID.
            //if (token == null || token == "null") {
            //    alert("系统错误，丢失了登录信息 token ,请重新登录。");
            //    return;
            //}
            //访问后台，获得一个工作ID.
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_TestingContainer");
            handler.AddPara("Token", token);
            handler.AddPara("UserNo", userNo);
            handler.AddPara("OrgNo", orgNo);
            var data = handler.DoMethodReturnString("Default_LetAdminerLogin");

            //先设置缓存为空.
            webUserJsonString = null;
            var webUser = new WebUser();

            var html = "<table style='width:100%;'>";
            html += "<caption class='top_tiitle'><a class='title_content' href='javascript:LetAdminerLogin();' ><i class='icon-arrow-left' style='font-size:14px;margin-right: 5px;'></i>返回流程设计器 </a></caption>";
            html += "<tr>";
            html += "<td colspan=2 style='text-align:center'>";
            html += "<img style='width:50%;' src='../../../DataUser/UserIcon/" + webUser.No + ".png' onerror=\"this.src='../../../DataUser/UserIcon/Default.png'\" />";
            html += "</td>";
            html += "</tr>";

            html += "<tr>";
            html += "<td class='left-user-end'>帐号</td>";
            html += "<td class='left-user-left'>" + webUser.No + "</td>";
            html += "</tr>";

            html += "<tr>";
            html += "<td class='left-user-end'>用户</td>";
            html += "<td class='left-user-left'>" + webUser.Name + "</td>";
            html += "</tr>";

            html += "<tr>";
            html += "<td class='left-user-end'>部门</td>";
            html += "<td class='left-user-left'>" + webUser.FK_DeptName + "</td>";
            html += "</tr>";
            html += "</table>";

            $("#userInfo").html(html);


            //   InitPageUserInfo();

            //if (data.indexOf('err@') == 0) {
            //    alert(data);
            //    return;
            //    //  data = GetQueryString("UserNo");
            //}

            //if (url.indexOf("SelectOneUser") == 0 || url.indexOf("SelectOneUser") == 0 )


            $("#J_iframe").attr('src', url + GenerUrlEnd());
            return false
        }


        //重新启动.
        function Restart() {
            localStorage.setItem("Token", "");
            webUserJsonString = null;
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_TestingContainer");
            handler.AddUrlData();
            var data = handler.DoMethodReturnString("Default_Init");
            if (data.indexOf('err@') == 0) {
                var url = 'error.htm?err=' + workID;

                confirm("测试容器发起错误，请参考以下信息：<\br>" + workID);
                window.close();
            }
            var str = data.split('@');
            workID = str[0];
            localStorage.setItem("Token", str[1]);
            InitPageUserInfo();
            document.getElementById("J_iframe").src = "../../MyFlow.htm?FK_Flow=" + flowNo + "&WorkID=" + workID;
        }

        function SelectOneUser() {

            alert('切换用户..');

            var url = "SelectOneUser.html?1=2" + GenerUrlEnd();
            $("#J_iframe").attr('src', url);
            LetAdminerLogin();

        }

        //如果关闭的时候，就让admin登录.
        function LetAdminerLoginLeft() {
            //  if (window.confirm('您确定要退出到管理员吗？') == false)
            //    return;
            LetAdminerLogin();
        }

        //关闭页面登录 admin.
        $(window).on('beforeunload', function (e) {
            //获取事件鼠标的位置
            var n = window.event.screenX - window.screenLeft;
            //获取浏览器界面可活动的窗口宽度（50是右上角关闭按钮的宽度）
            var b = n > document.documentElement.scrollWidth - 50;
            //window.event.clientY表示事件的y值（鼠标）
            //window.event.altKey表示是否按下列alt键（alt+F4）
            if (b && window.event.clientY < 0 || window.event.altKey) {
                LetAdminerLogin();
            } else {
                alert("是刷新而非关闭");
            }
            
        });


    </script>
    <style type="text/css">
        .top_tiitle {
            font-size: 18px;
        }

        .left-user-end {
            text-align: right;
        }

        .left-user-left {
            text-align: left;
        }

        .navbar-default {
            background-color: white !important;
        }

        .rightContent {
            box-sizing: border-box;
            float: left;
            box-sizing: border-box;
            padding-left: 200px;
            overflow-y: overlay;
            overflow-x: hidden;
            clear: both;
            color: #717592;
            min-width: 100%;
            min-height: 500px;
        }

        #userInfo caption {
            padding-right: 10px;
            height: 25px;
            text-align: center;
            text-indent: 0 !important;
            color: #000;
            border: none !important;
            border-bottom: solid 1px #ccc !important;
            background-color: #0237a1 !important;
        }
        .title_content{
            color:#fff;
        }
            .title_content:hover{
                color:#fff;
            }

            .navbar-default table {
                margin: 0 !important;
                border: none !important;
            }

            .navbar-default table td {
                padding: 5px 15px;
                border: none !important;
            }

        #Info ul {
            border: none !important;
            padding: 10px 10px 10px 35px;
            box-sizing: border-box;
        }

        .choose-active {
            background: #e1e1e1;
            color: #fff !important;
            border-radius: 5px;
        }
        #choose-parent li a {
            color: #0237a1;
        }
    </style>
</head>
<body class="fixed-sidebar full-height-layout gray-bg" style="overflow:hidden">
    <!--<div id="Guide"></div>-->
    <div id="wrapper">
        <!--左侧导航开始-->
        <nav class="navbar-default navbar-static-side" role="navigation" style="background-color:#fff!important;border-right:solid 1px #ccc;">
            <div class="sidebar-collapse">
                <div id="userInfo" style="box-sizing:border-box;"></div>
                <div style="background-color: #dee6f3 !important; padding: 10px 35px; border-top: solid 1px #ccc; border-bottom: solid 1px #ccc; color: #000; font-weight: bold; ">
                   <i class="icon-cloud-upload" style="margin-right:5px;"></i> 测试容器
                </div>
                <div class="sidebar-collapse" id="Info">
                </div>
                <!--<div style="background-color:#fff!important;text-align:center;padding:10px;border-top:solid 1px #ccc;border-bottom:solid 1px #ccc;color:#000;font-weight:bold;">
                    基础功能
                </div>
                <div class="sidebar-collapse" id="BaseInfo">
                </div>-->
            </div>
        </nav>
        <!--左侧导航结束-->
        <!--右侧部分开始-->
        <div id="page-wrapper" class="gray-bg dashbard-1" style="overflow:hidden">
            <div class="row J_mainContent" id="content-main" style="background:#fff;">
                <iframe id="J_iframe" width="100%" height="100%" frameborder="0" seamless></iframe>
            </div>
        </div>
        <!--右侧部分结束-->

    </div>
</body>
</html>
